package com.itsv.cyzx.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itsv.cyzx.bean.Me_DetailBean;
import com.itsv.xhyy.R;

public class PageListView_Adapter extends BaseAdapter {

	private ArrayList<Me_DetailBean> list = null;
	private LayoutInflater inflater = null;
	private TextView tv = null;

	public PageListView_Adapter(Context con, ArrayList<Me_DetailBean> list) {
		inflater = LayoutInflater.from(con);
		this.list = list;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		if (list == null) {
			return 0;
		}
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.page_item, null);
		}
		tv = (TextView) convertView.findViewById(R.id.tv_page);
		if (list.get(position).getTitle().length() > 14) {
			tv.setText(list.get(position).getTitle().subSequence(0, 12) + "...");
		} else {
			tv.setText(list.get(position).getTitle());
		}
		return convertView;
	}

}
